<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-06-20 09:50:14
 * @LastEditors: voanit
 * @LastEditTime: 2022-06-20 09:55:57
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var arr = [1, 2, 3]
    var obj = { id: 1, name: 'jack' }
    // for (var i = 0; i < arr.length; i++) {
    //   console.log(i);
    // }

    // for (const item of arr) {
    //   console.log(item);
    // }
    // for (const i in arr) {
    //   console.log(arr[i]);
    // }

    /* 
    for of  和  for  in  都可以遍历数组
    for of 不能遍历对象
    for in 能遍历对象
    */

    for (const item in obj) {
      console.log(item);
    }

  </script>
</body>

</html>